package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.ResearchPaper;
import com.ruoyi.personnel.mapper.ResearchPaperMapper;
import com.ruoyi.personnel.service.IResearchPaperService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 科研论文Service业务层处理
 *
 * @author ruoyi
 * @date 2021-03-02
 */
@Service
public class ResearchPaperServiceImpl extends ServiceImpl<ResearchPaperMapper, ResearchPaper> implements IResearchPaperService {

    @Override
    public List<ResearchPaper> queryList(ResearchPaper researchPaper) {
        LambdaQueryWrapper<ResearchPaper> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(researchPaper.getName())){
            lqw.like(ResearchPaper::getName ,researchPaper.getName());
        }
        if (StringUtils.isNotBlank(researchPaper.getJobNumber())){
            lqw.eq(ResearchPaper::getJobNumber ,researchPaper.getJobNumber());
        }
        if (StringUtils.isNotBlank(researchPaper.getPersonnelId())){
            lqw.eq(ResearchPaper::getPersonnelId ,researchPaper.getPersonnelId());
        }
        if (StringUtils.isNotBlank(researchPaper.getPaperName())){
            lqw.like(ResearchPaper::getPaperName ,researchPaper.getPaperName());
        }
        if (StringUtils.isNotBlank(researchPaper.getPublishTime())){
            lqw.eq(ResearchPaper::getPublishTime ,researchPaper.getPublishTime());
        }
        if (StringUtils.isNotBlank(researchPaper.getEnclosure())){
            lqw.eq(ResearchPaper::getEnclosure ,researchPaper.getEnclosure());
        }
        if (StringUtils.isNotBlank(researchPaper.getEnclosureName())){
            lqw.like(ResearchPaper::getEnclosureName ,researchPaper.getEnclosureName());
        }
        if (researchPaper.getOfficeId() != null){
            lqw.eq(ResearchPaper::getOfficeId ,researchPaper.getOfficeId());
        }
        if (StringUtils.isNotBlank(researchPaper.getOfficeName())){
            lqw.like(ResearchPaper::getOfficeName ,researchPaper.getOfficeName());
        }
        if (StringUtils.isNotBlank(researchPaper.getStatus())){
            lqw.eq(ResearchPaper::getStatus ,researchPaper.getStatus());
        }
        return this.list(lqw);
    }
}
